﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace HotelManager
{
    public class Engine
    {
        public List<Room> Rooms { get; set; }
        public List<Person> Guests { get; set; }
        public List<RentInfo> RentHistory { get; set; }
        public List<PurchaseInfo> PurchaseHistory { get; set; }
        public List<ReservationInfo> ReservationHistory { get; set; }
        public Recepcionist CurrentAccount { get; set; }
        public Serializer DataSerializer { get; set; }
        public RoomsManager RoomsManager { get; set; }

        public Engine()
        {
            this.CurrentAccount = new Recepcionist("Pesho", "Recepcionista", "Adresa na pesho", "Egn na pesho", "id na pesho", "telefon na pesho", "nacionalnost na pesho", 1000, 20);

            this.Rooms = new List<Room>();
            this.Guests = new List<Person>();
            this.RentHistory = new List<RentInfo>();
            this.ReservationHistory = new List<ReservationInfo>();
            this.PurchaseHistory = new List<PurchaseInfo>();
            this.DataSerializer = new Serializer();
            this.RoomsManager = new RoomsManager();
        }

        public void SaveData()
        {
            using (StreamWriter guestsDataWriter = new StreamWriter("engineData.txt"))
            {
                this.DataSerializer.HotelDataSerializer.Serialize(guestsDataWriter, this);
            }            
        }

        public Guest CreateGuest(string firstName, string lastName, string address, string egn, string id, string phone, string nationality)
        {
            Guest currentGuest = new Guest(firstName, lastName, address, egn, id, phone, nationality);

            return currentGuest;
        }

        public Manager CreateManager(string firstName, string lastName, string address, string egn, string id, string phone,
            string nationality, decimal salary, decimal discount)
        {
            Manager currentManager = new Manager(firstName, lastName, address, egn, id, phone, nationality, salary, discount);

            return currentManager;
        }

        public Recepcionist CreateRecepcionist(string firstName, string lastName, string address, string egn, string id, string phone,
            string nationality, decimal salary, decimal discount)
        {
            Recepcionist currentRecepcionist = new Recepcionist(firstName, lastName, address, egn, id, phone, nationality, salary, discount);

            return currentRecepcionist;
        }

        public ChamberMaid CreateCleaner(string firstName, string lastName, string address, string egn, string id, string phone,
            string nationality, decimal salary, decimal discount)
        {
            ChamberMaid currentChamberMaid = new ChamberMaid(firstName, lastName, address, egn, id, phone, nationality, salary, discount);

            return currentChamberMaid;
        }

        public Guard CreateGuard(string firstName, string lastName, string address, string egn, string id, string phone,
            string nationality, decimal salary, decimal discount)
        {
            Guard currentGuard = new Guard(firstName, lastName, address, egn, id, phone, nationality, salary, discount);

            return currentGuard;
        }

        public SingleRoom CreateSingleRoom()
        {
            SingleRoom currentRoom = new SingleRoom();

            return currentRoom;
        }

        public DoubleRoom CreateDoubleRoom()
        {
            DoubleRoom currentRoom = new DoubleRoom();

            return currentRoom;
        }

        public Apartment CreateApartment()
        {
            Apartment currentApartment = new Apartment();

            return currentApartment;
        }
    }
}
